package com.study.flink.entity.does;

import lombok.Data;

/**
 * @projectName: flink-training-exercises
 * @author: yandong
 * @description:
 * @date: 2019年7月11日 下午7:41:11
 * @version:
 * 
 * 
 *           , insert_date, origin, destination, start_date, end_date, train_type, price,
 *           train_class, fare
 * 
 *           0,2019-04-19 05:31:43, MADRID, SEVILLA, 2019-05-29 06:20:00, 2019-05-29 09:16:00, AV
 *           City, 38.55, Turista, Promo
 */
@Data
public class TicketsPricingDO {
    private String id;
    private String insertDate;
    private String origin;
    private String destination;
    private String startDate;
    private String endDate;
    private String trainType;
    private String price;
    private String trainClass;
    private String fare;

    public static TicketsPricingDO fromString(String text) {
        String[] fields = text.split(",");

        TicketsPricingDO ticketsPricingDO = new TicketsPricingDO();
        ticketsPricingDO.id = fields.length < 1 ? "" : fields[0].trim();
        ticketsPricingDO.insertDate = fields.length < 2 ? "" : fields[1].trim();
        ticketsPricingDO.origin = fields.length < 3 ? "" : fields[2].trim();
        ticketsPricingDO.destination = fields.length < 4 ? "" : fields[3].trim();
        ticketsPricingDO.startDate = fields.length < 5 ? "" : fields[4].trim();
        ticketsPricingDO.endDate = fields.length < 6 ? "" : fields[5].trim();
        ticketsPricingDO.trainType = fields.length < 7 ? "" : fields[6].trim();
        ticketsPricingDO.price = fields.length < 8 ? "" : fields[7].trim();
        ticketsPricingDO.trainClass = fields.length < 9 ? "" : fields[8].trim();
        ticketsPricingDO.fare = fields.length < 10 ? "" : fields[9].trim();

        return ticketsPricingDO;
    }
}
